package com.d3works.apps.stock.service;

import com.d3works.apps.base.db.Product;
import com.d3works.apps.base.db.repo.ProductRepository;
import com.d3works.apps.base.db.repo.ProductVariantRepository;
import com.d3works.apps.base.service.ProductVariantServiceImpl;
import com.d3works.apps.base.service.app.AppBaseService;
import com.d3works.inject.Beans;
import com.google.inject.Inject;

public class ProductVariantServiceStockImpl extends ProductVariantServiceImpl {

  @Inject
  public ProductVariantServiceStockImpl(
      ProductRepository productRepo, ProductVariantRepository productVariantRepo) {
    super(productRepo, productVariantRepo);
  }

  @Override
  public Product copyAdditionalFields(Product product, Product productModel) {
    product = super.copyAdditionalFields(product, productModel);
    if (Beans.get(AppBaseService.class).isApp("stock")) {
      product.setUsedInDEB(productModel.getUsedInDEB());
      product.setCustomsCodeNomenclature(productModel.getCustomsCodeNomenclature());
      product.setStockManaged(productModel.getStockManaged());
      product.setControlOnReceipt(productModel.getControlOnReceipt());
      product.setTrackingNumberConfiguration(productModel.getTrackingNumberConfiguration());
    }
    return product;
  }
}
